//
//  ViewController.m
//  UI_Homework_08_01
//
//  Created by 黄威 on 16/5/12.
//  Copyright © 2016年 黄威. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"
@interface ViewController () <SecondDelegate> //签订协议;
@property (nonatomic,retain)UILabel *label;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createfirst];
}


- (void)createfirst{

//创建label 和button
    
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(100, 150, 200, 40)];
    self.label.backgroundColor = [UIColor purpleColor];
    [self.view addSubview: self.label];
    self.label.text = @"测试";
    
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(100, 250, 200, 40)];
    button.backgroundColor = [UIColor purpleColor];
    [self.view addSubview:button];
    
    
    [self.label release];
    [button release];
    
    [button addTarget:self action:@selector(handle1) forControlEvents:UIControlEventTouchUpInside];


}

- (void)handle1{

    SecondViewController *second = [[SecondViewController alloc]init];
    second.contectOfsecond = self.label.text;
    
    second.delegate = self;
    [self.navigationController pushViewController:second animated:YES];

    [second release];

}
-(void)copysecondstring:(NSString *)string{


    self.label.text = string;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
